package com.doit.day02;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

public class SubscribeDemo {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("linux01", 6379);


        jedis.subscribe(new JedisPubSub() {
            @Override
            public void onMessage(String channel, String message) {
                //具体的逻辑处理
                if (channel.equals("A")){
                    //转换成小写
                    String res = message.toLowerCase();
                    System.out.println("这是从"+channel + "渠道发过来的消息，消息是:"+res);
                }else if(channel.equals("B")){
                    //转换成大写
                    String res = message.toUpperCase();
                    System.out.println("这是从"+channel + "渠道发过来的消息，消息是:"+res);
                }else{
                    String res = message + "____其他渠道";
                    System.out.println("这是从"+channel + "渠道发过来的消息，消息是:"+res);
                }
            }
        },"A","B","C","shell");
    }
}
